package com.qf.zyh.web.controller;

import com.qf.zyh.common.ResponseResult;
import com.qf.zyh.common.ResultType;
import com.qf.zyh.entity.ApiMapping;
import com.qf.zyh.services.ApiMappingServices;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mapping")
public class ApiMappingController {
    @Autowired
    private ApiMappingServices apiMappingServices;
    @RequestMapping("/table")
    public ResultType table(@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "5") Integer limit,String gatewayApiName, Integer state){
        return apiMappingServices.table(page,limit,gatewayApiName,state);
    }
    @RequestMapping("/del")
    public ResponseResult delMa(Integer[] ids){
        try {
            return apiMappingServices.delMa(ids);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseResult.getFail("删除错误啦");
    }
    @RequestMapping("/add")
    public ResponseResult addMa(ApiMapping a){
        try {
            return apiMappingServices.addMa(a);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseResult.getFail("添加错误啦");
    }
    @RequestMapping("/update")
    public ResponseResult updateMa(ApiMapping a){
        try {
            return apiMappingServices.updateMa(a);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseResult.getFail("修改错误啦");
    }

}
